From: Alessandro Astone Date: Tue, 9 Sep 2025 12:34:14 +0000 (+0200) Subject: st/button: Fix toggle-button with keyboard input X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~95^2^2~30 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=fcdc63b33ae886e3628d0b127e3dd0dcecd981cc;p=gnome-shell.git st/button: Fix toggle-button with keyboard input An St.Button with toggle-mode ON would not update the toggle state when invoked via keyboard input. Fixes: dd694bf1a ("st/button: Use ClutterClickGesture instead of own button-press tracking") Part-of: --- diff --git a/src/st/st-button.c b/src/st/st-button.c index 33724962b..f509cf4f3 100644 --- a/src/st/st-button.c +++ b/src/st/st-button.c @@ -120,6 +120,18 @@ st_button_style_changed (StWidget *widget) st_button_update_label_style (button); } +static void +handle_clicked (StButton *button, + unsigned int clicked_button) +{ + StButtonPrivate *priv = st_button_get_instance_private (button); + + if (priv->is_toggle) + st_button_set_checked (button, !priv->is_checked); + + g_signal_emit (button, button_signals[CLICKED], 0, clicked_button); +} + static void button_click_gesture_recognize_cb (ClutterPressGesture *press_gesture, StButton *button) @@ -130,10 +142,7 @@ button_click_gesture_recognize_cb (ClutterPressGesture *press_gesture, if ((priv->button_mask & ST_BUTTON_MASK_FROM_BUTTON (clicked_button)) == 0) return; - if (priv->is_toggle) - st_button_set_checked (button, !priv->is_checked); - - g_signal_emit (button, button_signals[CLICKED], 0, clicked_button); + handle_clicked (button, clicked_button); } static void @@ -201,7 +210,7 @@ st_button_key_release (ClutterActor *actor, { if (priv->key_pressed) { - g_signal_emit (button, button_signals[CLICKED], 0, ST_BUTTON_ONE); + handle_clicked (button, ST_BUTTON_ONE); st_widget_remove_style_pseudo_class (ST_WIDGET (actor), "active"); priv->key_pressed = FALSE; }